﻿using Microsoft.AspNetCore.Mvc;
using MVC系统mvc.Dto.Warehouse;
using Newtonsoft.Json;
using System.Reflection;
using WMS_MAV;
using static System.Net.WebRequestMethods;

namespace MVC系统mvc.Controllers
{
    /// <summary>
    /// 仓库控制器
    /// </summary>
    public class WarehouseController : Controller
    {
        private readonly IConfiguration _configuration;
        public WarehouseController(IConfiguration configuration)
        {
            _configuration = configuration;
        }
        /// <summary>
        /// 仓库添加视图
        /// </summary>
        /// <returns></returns>
        public IActionResult WarehouseAdd()
        {
            return View();
        }
        /// <summary>
        /// 仓库显示视图
        /// </summary>
        /// <returns></returns>
        public IActionResult WarehouseShow()
        {
            return View();
        }
        /// <summary>
        /// 仓库修改视图
        /// </summary>
        /// <returns></returns>
        public IActionResult WarehouseUpd()
        {
            return View();
        }
        /// <summary>
        /// 仓库查看视图
        /// </summary>
        /// <returns></returns>
        public IActionResult WarehouseLook()
        {
            return View();
        }
        /// <summary>
        /// 库位显示视图
        /// </summary>
        /// <returns></returns>
        public IActionResult WarehouseShowBin()
        {
            return View();
        }
        /// <summary>
        /// 库区显示视图
        /// </summary>
        /// <returns></returns>
        public IActionResult ReservoirsShow()
        {
            return View();
        }
        /// <summary>
        /// 仓库查看平面图视图
        /// </summary>
        /// <returns></returns>
        public IActionResult WarehousePlanShow()
        {
            return View();
        }
        /// <summary>
        /// 入库显示 
        /// </summary>
        /// <returns></returns>
        public IActionResult InventoryShow()
        {
            return View();
        }
        /// <summary>
        /// 入库详情 
        /// </summary>
        /// <returns></returns>
        public IActionResult InventoryInfo()
        {
            return View();
        }
        /// <summary>
        /// 入库修改  
        /// </summary>
        /// <returns></returns>
        public IActionResult InventoryUpd()
        {
            return View();
        }
        /// <summary>
        /// 入库添加  
        /// </summary>
        /// <returns></returns>
        public IActionResult InventoryAdd()
        {
            return View();
        }
        /// <summary>
        /// 出库显示 
        /// </summary>
        /// <returns></returns>
        public IActionResult OutInventoryShow()
        {
            return View();
        }
        /// <summary>
        /// 出库详情 
        /// </summary>
        /// <returns></returns>
        public IActionResult OutInventoryInfo()
        {
            return View();
        }
        /// <summary>
        /// 出库修改  
        /// </summary>
        /// <returns></returns>
        public IActionResult OutInventoryUpd()
        {
            return View();
        }
        /// <summary>
        /// 出库添加  
        /// </summary>
        /// <returns></returns>
        public IActionResult OutInventoryAdd()
        {
            return View();
        }
        /// <summary>
        /// 转库显示 
        /// </summary>
        /// <returns></returns>
        public IActionResult TransferShow()
        {
            return View();
        }
        /// <summary>
        /// 转库详情 
        /// </summary>
        /// <returns></returns>
        public IActionResult TransferInfo()
        {
            return View();
        }
        /// <summary>
        /// 转库修改  
        /// </summary>
        /// <returns></returns>
        public IActionResult TransferUpd()
        {
            return View();
        }
        /// <summary>
        /// 转库添加  
        /// </summary>
        /// <returns></returns>
        public IActionResult TransferAdd()
        {
            return View();
        }
        /// <summary>
        /// 生产领料显示 
        /// </summary>
        /// <returns></returns>
        public IActionResult PickingShow()
        {
            return View();
        }
        /// <summary>
        /// 生产领料修改  
        /// </summary>
        /// <returns></returns>
        public IActionResult PickingUpd()
        {
            return View();
        }
        /// <summary>
        /// 生产领料添加  
        /// </summary>
        /// <returns></returns>
        public IActionResult PickingAdd()
        {
            return View();
        }
        /// <summary>
        /// 生产领料查看(待审批) 
        /// </summary>
        /// <returns></returns>
        public IActionResult PickingNotApproved()
        {
            return View();
        }
        /// <summary>
        /// 生产领料查看(已审批)
        /// </summary>
        /// <returns></returns>
        public IActionResult PickingApproved()
        {
            return View();
        }
        /// <summary>
        /// 成品添加
        /// </summary>
        /// <returns></returns>
        public IActionResult FinishedProductAdd()
        {
            return View();
        }
        /// <summary>
        /// 成品显示
        /// </summary>
        /// <returns></returns>
        public IActionResult FinishedProductShow()
        {
            return View();
        }
        /// <summary>
        /// 成品修改
        /// </summary>
        /// <returns></returns>
        public IActionResult FinishedProductUpd()
        {
            return View();
        }
        /// <summary>
        /// 成品详情(启用)
        /// </summary>
        /// <returns></returns>
        public IActionResult FinishedProductInfoEnable()
        {
            return View();
        }
        /// <summary>
        /// 成品详情(禁用)
        /// </summary>
        /// <returns></returns>
        public IActionResult FinishedProductInfoDisable()
        {
            return View();
        }
        /// <summary>
        /// 仓库显示
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> GetWarehouseShow(WarehouseShowDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.token);
            string url = _configuration["Url"] + "ckgl/api/Warehouse/Show?PageIndex=" + dto.Pageindex + "&PageSize=" + dto.Pagesize + "&WarehouseNo=" + dto.WarehouseNo + "&LocationCoding=" + dto.LocationCoding + "&WarehouseState=" + dto.WarehouseState;
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 仓库返填
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> WarehouseBackfill(WarehouseBackfillDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.token);
            string url = _configuration["Url"] + "ckgl/api/Warehouse/Backfill?WarehouseId=" + dto.WarehouseId;
            //var datas = JsonConvert.SerializeObject(url);
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 仓库删除
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> DelWarehouse(int WarehouseId, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/Warehouse/Delete?WarehouseId=" + WarehouseId;
            var datas = JsonConvert.SerializeObject(WarehouseId);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        /// 仓库添加
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> AddWarehouse(WarehouseAddDTO dto, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/Warehouse/Create";
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        /// 库位添加
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> AddWarehouseBin(BinAddDTO dto, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/BinLocations/CreateBinLocations";
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        /// 仓库显示（二级联动）
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> GetWarehouseList(string token)
        {

            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/BinLocations/GetWarehousesList";
            // var datas = JsonConvert.SerializeObject(dto);
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 库区显示（二级联动）
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> GetReserList(int WarehouseId, string token)
        {

            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/BinLocations/GetReservoirsList?WarehouseId=" + WarehouseId;
            // var datas = JsonConvert.SerializeObject(dto);
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 库位显示
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> GetWarehouseShowBin(WarehouseShowBinDTO dto)
        {

            HttpClientWrapper client = new HttpClientWrapper(dto.token);
            string url = _configuration["Url"] + "ckgl/api/BinLocations/GetBinLocationsList?BinLocationNo=" + dto.BinLocationNo + "&BinLocationName=" + dto.BinLocationName + "&BinLocationState=" + dto.BinLocationState + "&PageIndex=" + dto.PageIndex + "&PageSize=" + dto.PageSize;
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 库位删除
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> DelWarehouseBin(int BinLocationId, string token)
        {

            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/BinLocations/DeleteBinLocations?BinLocationId=" + BinLocationId;
            var datas = JsonConvert.SerializeObject(BinLocationId);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        /// 库位反填
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> GetByWarehouseBin(int BinLocationId, string token)
        {

            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/BinLocations/HandleBinLocations?BinLocationId=" + BinLocationId;
            var datas = JsonConvert.SerializeObject(BinLocationId);
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 库位修改
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> UpdateWarehouseBin(BinAddDTO dto, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/BinLocations/UpdateBinLocations";
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        /// 仓库修改
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> UpdWarehouse(WarehouseAddDTO dto, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/Warehouse/Update";
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        ///库区显示
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> GetReservoirsShow(ReservoirShowDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.token);
            string url = _configuration["Url"] + "ckgl/api/Reservoirs/Show?PageIndex=" + dto.Pageindex + "&PageSize=" + dto.Pagesize + "&ReservoirName=" + dto.ReservoirName + "&ReservoirNo=" + dto.ReservoirNo;
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 库区添加
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> AddReservoirs(ReservoirAddDTO dto, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/Reservoirs/Create";
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        /// 库区删除
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> DelReservoirs(int ReservoirId, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/Reservoirs/Delete?ReservoirId=" + ReservoirId;
            var datas = JsonConvert.SerializeObject(ReservoirId);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        /// 库区返填
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> ReservoirBackfill(ReservoirBackfillDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.token);
            string url = _configuration["Url"] + "ckgl/api/Reservoirs/Backfill?ReservoirId=" + dto.ReservoirId;
            //var datas = JsonConvert.SerializeObject(url);
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 仓库修改
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> UpdReservoir(ReservoirAddDTO dto, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/Reservoirs/Update";
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        /// 显示仓库平面图
        /// </summary> 
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> WarehousePlanShowMethod(WarehousePlanShowDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.token);
            string url = _configuration["Url"] + "ckgl/api/Warehouse/WarehousePlan?ReservoirArea=" + dto.ReservoirArea;
            //var datas = JsonConvert.SerializeObject(url);
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 显示库区详情通过仓库id
        /// </summary> 
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> ReservoirsShowByWarehouseId(ReservoirsShowByWarehouseIdDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.token);
            string url = _configuration["Url"] + "ckgl/api/Reservoirs/ShowReservoirsByWarehouseId?WarehouseId=" + dto.WarehouseId;
            //var datas = JsonConvert.SerializeObject(url);
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 显示库位详情通过库区id(三级联动)
        /// </summary> 
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> BinlocationShowByRId(int ReservoirId, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/BinLocations/BinLocationsShowByRId?ReservoirId=" + ReservoirId;
            //string url = "http://localhost:15950/api/BinLocations/BinLocationsShowByRId?ReservoirId=" + ReservoirId;
            //var datas = JsonConvert.SerializeObject(url);
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 显示库位详情通过仓库id
        /// </summary> 
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> BinLocationShowByReservoirId(ReservoirsShowByWarehouseIdDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.token);
            string url = _configuration["Url"] + "ckgl/api/BinLocations/BinLocationsShowByReservoirId?WarehouseId=" + dto.WarehouseId;
            //var datas = JsonConvert.SerializeObject(url);
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 入库显示
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> GetInventoryShow(InventoryShowDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.token);
            string url = _configuration["Url"] + "ckgl/api/Inventory/Show?InventoryNo=" + dto.InventoryNo + "&FinishedProductNo=" + dto.FinishedProductNo + "&InventoryState=" + dto.InventoryState;
            //string url = "http://localhost:15950/api/Inventory/Show?InventoryNo=" + dto.InventoryNo + "&FinishedProductNo=" + dto.FinishedProductNo + "&InventoryState=" + dto.InventoryState;
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 入库删除
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> DelInventory(int InventoryId, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/Inventory/Delete?InventoryId=" + InventoryId;
            //string url = "http://localhost:15950/api/Inventory/Delete?InventoryId=" + InventoryId;
            var datas = JsonConvert.SerializeObject(InventoryId);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        /// 入库添加
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> AddInventory(StorageAddDTO dto, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/Inventory/Create";
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        /// 入库返填
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> GetInventoryBackfill(int InventoryId, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/Inventory/Backfill?InventoryId=" + InventoryId;
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 入库修改
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> UpdInventory(StorageAddDTO dto, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/Inventory/Update";
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        /// 采购信息反填(入库)
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> FabPurchRu(string token, int PurchaseID)
        {

            HttpClientWrapper client = new HttpClientWrapper(token);
            //string url = "http://localhost:59256/api/Pruch/GetPuridList?PurchaseID=" + PurchaseID;
            string url = _configuration["Url"] + "/purech/api/Pruch/GetPuridList?PurchaseID=" + PurchaseID;
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 入库修改状态
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> UpdInventoryState(int InventoryId, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/Inventory/UpdState?InventoryId=" + InventoryId;
            //string url = "http://localhost:15950/api/Inventory/UpdState?InventoryId=" + InventoryId;
            var datas = JsonConvert.SerializeObject(InventoryId);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        /// 出库显示
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> GetOutInventoryShow(OutInventoryShowDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.token);
            string url = _configuration["Url"] + "ckgl/api/Inventory/OutShow?InventoryNo=" + dto.InventoryNo + "&FinishedProductNo=" + dto.FinishedProductNo + "&InventoryState=" + dto.InventoryState;
            //string url = "http://localhost:15950/api/Inventory/Show?InventoryNo=" + dto.InventoryNo + "&FinishedProductNo=" + dto.FinishedProductNo + "&InventoryState=" + dto.InventoryState;
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 出库添加
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> AddOutInventory(OutInventoryAddDTO dto, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/Inventory/Create";
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        /// 出库修改
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> UpdOutInventory(OutInventoryAddDTO dto, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/Inventory/Update";
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        /// 转库显示
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> GetTransferShow(TransferShowDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.token);
            string url = _configuration["Url"] + "ckgl/api/Inventory/TransferShow?InventoryNo=" + dto.InventoryNo + "&FinishedProductNo=" + dto.FinishedProductNo + "&InventoryState=" + dto.InventoryState;
            //string url = "http://localhost:15950/api/Inventory/Show?InventoryNo=" + dto.InventoryNo + "&FinishedProductNo=" + dto.FinishedProductNo + "&InventoryState=" + dto.InventoryState;
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 转库添加
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> AddTransfer(TransferAddDTO dto, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/Inventory/Create";
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        /// 转库修改
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> UpdTransfer(TransferAddDTO dto, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/Inventory/Update";
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }

        /// <summary>
        /// 仓库信息连表反填
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> ReverseByWarehouse(int WarehouseId, string token)
        {

            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/Warehouse/WarehousesReverse?WarehouseId=" + WarehouseId;
            var datas = JsonConvert.SerializeObject(WarehouseId);
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 生产领料添加
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> AddPicking(PickingAddDTO dto, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            //string url = _configuration["Url"] + "ckgl/api/Warehouse/Create";
            string url = "http://localhost:15950/api/Warehouse/Create";
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        } 
        /// <summary>
        /// 成品显示
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> GetFinishedProductShow(FinishedProductShowDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.token);
            string url = _configuration["Url"] + "ckgl/api/FinishedProduct/Show?FinishedProductNo=" + dto.FinishedProductNo + "&FinishedProductState=" + dto.FinishedProductState;
        
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 成品返填
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> FinishedProductBackfill(FinishedProductBackfillDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.token);
            string url = _configuration["Url"] + "ckgl/api/FinishedProduct/Backfill?FinishedProductId=" + dto.FinishedProductId;
            //string url = "http://localhost:15950/api/FinishedProduct/Backfill?FinishedProductId=" + dto.FinishedProductId;
            var response = await client.GetAsync(url);
            return Json(response);
        }
        /// <summary>
        /// 成品删除
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> DelFinishedProduct(int FinishedProductId, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/FinishedProduct/Delete??FinishedProductId=" + FinishedProductId;
            //string url = "http://localhost:15950/api/FinishedProduct/Delete?FinishedProductId=" + FinishedProductId;
            var datas = JsonConvert.SerializeObject(FinishedProductId);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        /// 成品添加
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> PostFinishedProductAdd(FinishedProductDTO dto, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/FinishedProduct/Create";
            //string url = "http://localhost:15950/api/FinishedProduct/Create";
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
        /// <summary>
        /// 成品修改
        /// </summary>
        /// <param name="warehouse"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> PostFinishedProductUpd(FinishedProductDTO dto, string token)
        {
            HttpClientWrapper client = new HttpClientWrapper(token);
            string url = _configuration["Url"] + "ckgl/api/FinishedProduct/Update";
            //string url = "http://localhost:15950/api/FinishedProduct/Update";
            var datas = JsonConvert.SerializeObject(dto);
            var response = await client.PostAsync(url, datas);
            return Json(response);
        }
    }
}
